function [B,e] = comprimir(fileName, k) 
    A = imread(fileName);
    [U,S,V] = svd(double(A));
    [fu,cu] = size(U);
    [fv,cv] = size(V);
    Ua = U(1:fu,1:k);
    Va = V(1:fv,1:k);
    Sa = S(1:k,1:k);
    B = Ua*Sa*Va';
    e = errorCuadraticoMedio(A, B);
    imshow(B);
    %pause
    
    
function e = errorCuadraticoMedio(A, B) 
    [fa,ca] = size(A);
    [fb,cb] = size(B);
    e = 0;
    for I = 1:fb
        for J = 1:cb
            e = e +  (power( double(A(I,J) - B(I,J)),2));
        end
    end
    e = e/(fb*cb);
    
   